package com.algorighm.hqy;

/**
 * @Classname BinaryTree
 * @Date 2019/9/19 16:10
 * @auther by hqy
 */
public class BinaryTree<T> {
    private DataNode root;


    public DataNode getRoot() {
        return root;
    }

    public void setRoot(DataNode root) {
        this.root = root;
    }

    public DataNode preOrder(T t) {
        if (root == null) {
            System.out.println("树为空~~~~~");
            return null;
        }
        return this.root.preOrder(t);

    }

    public DataNode infixOrder(T t) {

        if (root == null) {
            System.out.println("树为空~~~~~");
            return null;
        }
        return this.root.infixOrder(t);
    }

    public DataNode postOrder(T t) {

        if (root == null) {
            System.out.println("树为空~~~~~");
            return null;
        }
        return this.root.postOrder(t);
    }

    /**
     * @param []
     * @return void
     * @Description 前序遍历
     */
    public void preOrder() {
        if (root == null) {
            System.out.println("树为空~~~~~");
            return;
        }
        this.root.preOrder();

    }

    /**
     * @param []
     * @return void
     * @Description 中序遍历
     */
    public void infixOrder() {
        if (root == null) {
            System.out.println("树为空~~~~~");
            return;
        }
        this.root.infixOrder();

    }

    /**
     * @param []
     * @return void
     * @Description 后序遍历
     */
    public void postOrder() {
        if (root == null) {
            System.out.println("树为空~~~~~");
            return;
        }
        this.root.postOrder();

    }
}
